import dayjs from "dayjs";
import { ManipulateType } from "dayjs";
// 日期类型

export function formatDate(
  newData: Date | string = new Date(),
  ago: number,
  unit: ManipulateType
): string[] {
  let newArr: string[] = [];

  for (let i: number = 0; i < ago; i++) {
    let element = dayjs(newData).subtract(i, unit).format("YYYY-MM-DD");
    newArr.push(element);
  }

  return newArr.reverse();
}
